#!/bin/bash
# 作用：启/停Hadoop集群
if [ $# -ne 1 ]
then
	echo "请输入正确的指令start/stop！" && exit
fi
case $1 in
"start")
	echo "========== 启动Hadoop集群 =========="
	echo "----------    启动HDFS    ----------"
	ssh hadoop102 "start-dfs.sh"
	echo "----------  	启动YARN    ----------"
	ssh hadoop103 "start-yarn.sh"
	echo "---------- 启动历史服务器 ----------"
	ssh hadoop102 "mapred --daemon start historyserver"
;;
"stop")
	echo "========== 停止Hadoop集群 =========="
	echo "---------- 停止历史服务器 ----------"
	ssh hadoop102 "mapred --daemon stop historyserver"
	echo "----------  	停止YARN    ----------"
	ssh hadoop103 "stop-yarn.sh"
	echo "----------    停止HDFS    ----------"
	ssh hadoop102 "stop-dfs.sh"
;;
*)
	echo "请输入正确的指令start/stop!" && exit
;;
esac